package com.earnings.okhttputils.utils.ui.activity.user;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.earnings.R;
import com.earnings.okhttputils.utils.OkHttp.OkHttpUtils;
import com.earnings.okhttputils.utils.OkHttp.utils.ToastUtils;
import com.earnings.okhttputils.utils.UrlConstant.HttpUrl;
import com.earnings.okhttputils.utils.god.GodLeftHandBaseActivity;
import com.earnings.okhttputils.utils.https.HttpMap;
import com.earnings.okhttputils.utils.https.HttpObjectCallback;
import com.earnings.okhttputils.utils.ui.activity.common.StatusActivity;
import com.earnings.okhttputils.utils.utils.CommonUtil;

import java.util.Map;

/*
编辑用户信息-添加银行卡
 */
public class UserEditBankSureActivity extends GodLeftHandBaseActivity implements View.OnClickListener {


    TextView name,idcard,phone,bankcard,banktype;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }

    @Override
    protected int onCreateLayoutId() {
        return R.layout.activity_user_edit_bank_sure;
    }

    @Override
    protected void init() {
        setTitle("确认银行卡信息");
        bankcard= (TextView) findViewById(R.id.bankcard);
        idcard= (TextView) findViewById(R.id.idcard);
        name= (TextView) findViewById(R.id.name);
        phone= (TextView) findViewById(R.id.phone);
        banktype= (TextView) findViewById(R.id.banktype);
/*
      //  clearName=findViewById(R.id.clearName);
       // clearCard=findViewById(R.id.clearCard);

        findViewById(R.id.clearPhone).setOnClickListener(this);
        findViewById(R.id.clearCard).setOnClickListener(this);*/
        findViewById(R.id.sumbit).setOnClickListener(this);
        name.setText( CommonUtil.getUser().getRealname() );
        idcard.setText( CommonUtil.getUser().getIdcard() );
        banktype.setText(  bundleData.getString( "bank" ) );
        bankcard.setText( bundleData.getString( "bankcard" ) );
        phone.setText( bundleData.getString( "phone" ) );
    }


    @Override
    public void onClick(View v) {

        int i = v.getId();
        if (i == R.id.sumbit) {
            sureBindBank();
        }
    }

    public void sureBindBank() {
        Map map = new HttpMap(getContext());

        map.put( "id",bundleData.getString( "id" ));

        OkHttpUtils.post().url( HttpUrl.USER_BANK_SURE_URL ).params( map ).build().execute( new HttpObjectCallback<String>(  getContext()) {
            @Override
            public void onSuccess(String object, String msg) {

                bundleData.putString( "title", "添加成功" );
                bundleData.putString( "info", "您已成功添加"+bundleData.getString( "bank" ) );
                skipActivity( StatusActivity.class );
                finish();
            }
            @Override
            public void onFail(int code, String msg) {
                ToastUtils.showToast( getContext(),msg );
            }


        } );

    }

}
